{smcl}
{com}{sf}{ul off}{txt}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\MB\Desktop\JOP_Replicate\ReplicationUpload\LogforAppendixFigure1.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res} 9 Feb 2023, 19:23:19

{com}. do "C:\Users\MB\AppData\Local\Temp\STD52ac_000000.tmp"
{txt}
{com}. *** This code replicates Appendix Section E. Why Deal Results are Inconclusive 
. 
. ***Appendix Figure 1: Selecting responses by audience size suppresses the estimated effect of deals when all three responses are assumed to have similar effects in the data generating process.
. 
. ** Start with a blank Stata instance, no need to load any data sets
. *** Depending on the processor, it may take a while to finish the simulation 
. 
. capture program drop simulad
{txt}
{com}. program define simulad, rclass
{txt}  1{com}. clear
{txt}  2{com}. set obs 100
{txt}  3{com}. qui gen audience =  1 + floor(20*uniform())
{txt}  4{com}. tab audience
{txt}  5{com}. qui gen tolerance = uniform()<.1
{txt}  6{com}. count if tolerance == 1
{txt}  7{com}. scalar tolno = r(N)
{txt}  8{com}. qui gen attack = 1 if audience >= 6 & tolerance==0 & uniform()<=.25
{txt}  9{com}. qui replace attack= 0 if attack==.
{txt} 10{com}. count if attack == 1
{txt} 11{com}. scalar attno = r(N)
{txt} 12{com}. qui gen deal = 1 if audience < 6 & tolerance==0 & uniform()<=.35
{txt} 13{com}. qui replace deal= 0 if deal==.
{txt} 14{com}. count if deal == 1
{txt} 15{com}. scalar dealno = r(N)
{txt} 16{com}. 
. expand audience
{txt} 17{com}. qui gen startlatent2 = 1.5 -attack + deal + tolerance +2*rnormal()
{txt} 18{com}. qui gen start2 = startlatent2>=0
{txt} 19{com}. 
. probit start2 attack deal tolerance
{txt} 20{com}. 
. scalar attco = e(b)[1,1]
{txt} 21{com}. scalar dealco = e(b)[1,2]
{txt} 22{com}. scalar tolco = e(b)[1,3]
{txt} 23{com}. 
. scalar attsd = sqrt(e(V)[1,1])
{txt} 24{com}. scalar dealsd = sqrt(e(V)[2,2])
{txt} 25{com}. scalar tolsd = sqrt(e(V)[3,3])
{txt} 26{com}. 
. return scalar attco = attco 
{txt} 27{com}. return scalar attsd = attsd
{txt} 28{com}. return scalar attno = attno
{txt} 29{com}. return scalar dealco = dealco
{txt} 30{com}. return scalar dealsd =dealsd
{txt} 31{com}. return scalar dealno = dealno
{txt} 32{com}. return scalar tolco = tolco
{txt} 33{com}. return scalar tolsd = tolsd
{txt} 34{com}. return scalar tolno = tolno
{txt} 35{com}. 
. end
{txt}
{com}. 
. 
. set seed 1234567
{txt}
{com}. simulate ano = r(attno) dno = r(dealno) tno = r(tolno) aco = r(attco) dco = r(dealco) tco = r(tolco) asd = r(attsd) dsd = r(dealsd) tsd = r(tolsd), dots(1000) reps(100000): simulad 
{res}{p2colset 7 16 20 2}{...}

{txt}{p2col :Command:}{res:simulad}{p_end}
{p2colset 11 16 20 2}{...}
{p2col :ano:}{res:r(attno)}{p_end}
{p2colset 11 16 20 2}{...}
{p2col :dno:}{res:r(dealno)}{p_end}
{p2colset 11 16 20 2}{...}
{p2col :tno:}{res:r(tolno)}{p_end}
{p2colset 11 16 20 2}{...}
{p2col :aco:}{res:r(attco)}{p_end}
{p2colset 11 16 20 2}{...}
{p2col :dco:}{res:r(dealco)}{p_end}
{p2colset 11 16 20 2}{...}
{p2col :tco:}{res:r(tolco)}{p_end}
{p2colset 11 16 20 2}{...}
{p2col :asd:}{res:r(attsd)}{p_end}
{p2colset 11 16 20 2}{...}
{p2col :dsd:}{res:r(dealsd)}{p_end}
{p2colset 11 16 20 2}{...}
{p2col :tsd:}{res:r(tolsd)}{p_end}

Simulations ({res}100,000{txt})
{hline 4}{c +}{hline 3} 1 {hline 3}{c +}{hline 3} 2 {hline 3}{c +}{hline 3} 3 {hline 3}{c +}{hline 3} 4 {hline 3}{c +}{hline 3} 5 
.................................................. 50000
.................................................. 100000

{com}. 
. qui gen tatt = aco / asd
{txt}
{com}. qui gen tdeal = dco / dsd
{txt}
{com}. qui gen ttol = tco / tsd
{txt}
{com}. 
. 
. twoway (kdensity ttol)  (kdensity tatt)  (kdensity tdeal), xline(-1.96 1.96, lpattern(dash))  legend(label(1 "Toleration") label(2 "Attack") label (3 "Deal")) xtitle("T-scores") title("Simulating the Significance of Regression Coefficients")
{res}{txt}
{com}. 
{txt}end of do-file

{com}. 